/* jshint esversion: 6 */
import Home from './components/Home.vue'
import Menu from './components/Menu.vue'
import Login from './components/Login.vue'
import Register from './components/Register.vue'
import Admin from './components/Admin.vue'
import About from './components/about/About.vue'

//二级路由
import Contact from './components/about/Contact.vue'
import Delivery from './components/about/Delivery.vue'
import History from './components/about/History'
import OrderingGuide from './components/about/OrderingGuide'

//三级路由
//import Phone from './components/about/contact/Phone.vue'
//import PersonName from './components/about/contact/PersonName.vue'

export const routes = [
    {
        path:"/", name:'homeLink', 
        components:{
            default:Home,
            'orderingGuide':OrderingGuide,
            'delivery':Delivery,
            'history':History
        }
    },
    {path:"/menu", name:'menuLink', component:Menu},
    {path:"/login", name:'loginLink', component:Login},
    {path:"/register", name:'registerLink', component:Register},
  
    {path:"/admin", name:'adminLink', component:Admin, 
      // 路由独享守卫
      // beforeEnter:(to, from, next)=>{
      //   // alert("路由独享守卫")
      //   // next(false)
      //   if(to.path=='/login' || to.path=='register') {
      //     next()
      //   } else {
      //     alert("还没登录")
      //     next('/login')
      //   }
      // }
    },
  
    {
      path:"/about", 
      name:'aboutLink',
      redirect:'/about/contact',
      component:About, 
      children:[
        {
          path:"/about/contact", 
          name:'contactLink', 
          redirect:"/personname",
          component:Contact,
          children:[
            //{path:"/phone", name:'phoneNumber', component:Phone},
            {path:"/phone", name:'phoneNumber', component:resolve => require(['./components/about/contact/Phone'], resolve)},
            {path:"/personname", name:'personName', component:resolve => require(['./components/about/contact/PersonName'], resolve)}
          ]
        },
        {path:"/history", name:'historyLink', component:History},
        {path:"/orderGuide", name:'orderingGuideLink', component:OrderingGuide},
        {path:"/delivery", name:'deliveryLink', component:Delivery}
      ]
    },
    {path:"*", redirect:"/"}
  ]